package cn.edu.gdut.deepcode;

import cn.edu.gdut.deepcode.config.CheckCanvasIdValidatedExecutorServiceProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;

@SpringBootApplication
@MapperScan("cn.edu.gdut.deepcode.mapper")
@EnableAspectJAutoProxy
public class MockCanvasApplication {

    @Bean
    public ExecutorService checkCanvasIdValidatedExecutorService(
            CheckCanvasIdValidatedExecutorServiceProperties properties){
        return new ThreadPoolExecutor(
            properties.getCoreSize(),
                properties.getMaxSize(),
                properties.getAliveTime(),
                properties.getTimeUnit(),
                new LinkedBlockingQueue<>(),
                new ThreadPoolExecutor.AbortPolicy()
        );
    }

    public static void main(String[] args) {
        SpringApplication.run(MockCanvasApplication.class,args);
    }
}